package cn.fl.spl.service.impl;

import cmm.mid.core.framework.page.Pager;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.spl.service.IRegAddrRelViewService;
import cn.fl.spl.transform.RegAddrRelInfoViewVOTransform;
import cn.fl.spl.vo.RegAddrRelInfoViewVO;
import fl.spl.facade.framework.constant.SplSystemConstant;
import fl.spl.facade.view.api.IRegAddrRelInfoViewApiService;
import fl.spl.facade.view.condition.RegAddrRelInfoViewQC;
import fl.spl.facade.view.dto.RegAddrRelInfoViewDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class RegAddrRelViewServiceImpl implements IRegAddrRelViewService {

	@Autowired
	private IRegAddrRelInfoViewApiService regAddrRelInfoViewApiService ;

	@Override
	public Pager searchListPage(Pager page) throws BaseException {
		// TODO Auto-generated method stub
		if(page == null){
			page = new Pager();
		}
		Pager pager = this.regAddrRelInfoViewApiService.selectRegAddrRelInfoViewByPage(page, SplSystemConstant.FL_SYS_CD, CurrentThreadContext.CURRENT_ORG_CD, SplSystemConstant.FL_WEB_CHL_CD );
		List<RegAddrRelInfoViewDTO> resultList = (List<RegAddrRelInfoViewDTO>)pager.getResultList();
		if(CollectionUtils.isNotEmpty(resultList)){
			List<RegAddrRelInfoViewVO> voList = RegAddrRelInfoViewVOTransform.toVOList(resultList);
			pager.setResultList(voList);
		}
		return pager;
	}

	@Override
	public List<RegAddrRelInfoViewVO> searchList(RegAddrRelInfoViewQC qc) throws BaseException {
		// TODO Auto-generated method stub
		return null;
	}

}
